package wangjg.coco.views;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;

public class AbstractDialog extends Dialog {

	protected AbstractDialog(Shell parentShell) {
		super(parentShell);
	}
	
	protected void setGridLayout(Composite composite, int numColumns){
		GridLayout gridLayout = new GridLayout();
		gridLayout.numColumns = numColumns;
		gridLayout.makeColumnsEqualWidth=false;//?
		composite.setLayout(gridLayout);
	}


	protected GridData setGridData(Control control, Integer rowSpan){
		return this.setGridData(control, rowSpan, null, SWT.FILL);
	}
	
	protected GridData setGridData(Control control, Integer rowSpan, Integer colSpan, int horizontalAlignment){
		GridData gd = new GridData();
		gd.horizontalSpan = rowSpan;
		if(colSpan!=null){
			gd.verticalSpan = colSpan;
		}
		gd.horizontalAlignment = horizontalAlignment;
		gd.grabExcessHorizontalSpace = true;//?
		control.setLayoutData(gd);
		return gd;
	}
	
}
